package com.xbjtech.model;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import com.alibaba.fastjson.annotation.JSONField;
import com.google.gson.annotations.SerializedName;

import lombok.Data;

@Table(name = "resource")
@Data
public class Resource implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -2599695509402452051L;

	@Id
    private Integer id;

	@JSONField(name = "text") // fastjosn
	@SerializedName("text")   // gson
	// @JsonProperty("text")  // jackson
	@NotBlank(message = "资源名称不能为空")
    private String name;

    private String url;

    @NotBlank(message = "资源代码不能为空")
    private String code;

    @JSONField(name = "_parentId") // Fastjson
    @SerializedName("_parentId") // Gson
    private Integer parId;

    @NotNull(message = "优先级不能为空")
    private Integer priority;
    
    @Transient
    private List<Resource> children;

}